﻿using System;
using System.Collections.Generic;
using System.Text;
using NetworkLib.Utilities;

namespace PokemonBattle.RoomList.Client
{
    public class RoomSequence
    {
        private List<Room> _elements = new List<Room>();

        public List<Room> Elements
        {
            get { return _elements; }
        }

        public void WriteToByteArray(ByteArray byteArray)
        {
            byteArray.WriteInt(_elements.Count);

            foreach (Room elem in _elements)
            {
                elem.WriteToByteArray(byteArray);
            }
        }

        public void ReadFromByteArray(ByteArray byteArray)
        {
            int cnt = byteArray.ReadInt();

            for (int i = 0; i < cnt; i++)
            {
                Room elem = new Room();
                elem.ReadFromByteArray(byteArray);
                _elements.Add(elem);
            }
        }
    }
}
